package com.main.pojo;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity  
@Table(name = "TROLL")  
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)  
@DiscriminatorColumn(name="TrollType",discriminatorType=DiscriminatorType.STRING)  
@DiscriminatorValue(value="TROLL") 
public class Troll implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -473466146074563916L;
	
	protected int id;
	protected String title;
	protected String source;// nguon suu tam/tu che
	protected int viewNumber;
	protected Uploader uploader;
	protected Date postDate;
	protected String status;
	protected int commentNumber;
	
	public Troll(){
		
	}
	
	@Id
	@GenericGenerator(name="generator", strategy= "increment")
	@GeneratedValue(generator="generator")
//	@GeneratedValue(strategy = GenerationType.AUTO)
//	@Column(name="Id")
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	@Column(name="Title")
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	
	@Column(name="Source")
	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}
	
	@Column(name="ViewNumber")
	public int getViewNumber() {
		return viewNumber;
	}
	public void setViewNumber(int viewNumber) {
		this.viewNumber = viewNumber;
	}
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "UploaderId", nullable = false)
	public Uploader getUploader() {
		return uploader;
	}
	public void setUploader(Uploader uploader) {
		this.uploader = uploader;
	}
	
	@Column(name="PostDate")
	public Date getPostDate() {
		return postDate;
	}
	public void setPostDate(Date postDate) {
		this.postDate = postDate;
	}

	@Column(name="Status")
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}

	@Column(name="CommentNumber")
	public int getCommentNumber() {
		return commentNumber;
	}

	public void setCommentNumber(int commentNumber) {
		this.commentNumber = commentNumber;
	}
	
	
}
